package com.whw.springboot.bcucb.controller;

import com.whw.springboot.bcucb.config.GlobalConfig;
import com.whw.springboot.bcucb.utils.LoadUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Api(tags = "案例")
@RestController
@RequestMapping("/api/Case")
public class CaseController {

    @Resource
    private GlobalConfig globalConfig;



    @ApiOperation(value = "上传文件")
    @PostMapping(value = "/load",headers = "content-type=multipart/form-data")
    public String loadFile(@RequestParam(value = "file") MultipartFile[] files, RedirectAttributes redirectAttributes, HttpServletRequest request) throws IOException {

        return globalConfig.hostUrl+"resource/"+ LoadUtil.upload(globalConfig.filePath,files, request);
    }



}
